﻿@model IEnumerable<mock_ehr_lib.Model.Patient>
<h2>Patient Search</h2>
<p>Select your current patient</p>
<table>
    <thead>
    <tr>
        <th>
            First Name
        </th>
        <th>
            Last Name
        </th>
        <th>
            DOB
        </th>
        <th>
        </th>
    </tr>
    </thead>
    
    @foreach (var p in Model)
    {
        <tr>
            <td>
                @if (string.IsNullOrWhiteSpace(@p.Summary.GivenName))
                {
                    @p.FirstName
                }
                else
                {
                    @p.Summary.GivenName
                }
            </td>
            <td>
                @if (string.IsNullOrWhiteSpace(@p.Summary.FamilyName))
                {
                    @p.LastName
                }
                else
                {
                    @p.Summary.FamilyName
                }
            </td>
            <td>
                @if (@p.Summary.DOB.HasValue)
                {
                    @p.Summary.DOB.Value.ToString("MM/dd/yyyy")  
                }
                else
                {
                    @p.DOB
                }
            </td>
            <td>
                @Html.ActionLink("Select", "Index", "Patient", new { @p.ID }, null)
            </td>
        </tr>
    }
</table>
